var config = require('../config/config');//
var url=require('url');

module.exports = function (req, res, next) {
    //var reqUrl = req.url.split('?')[0];
    var result=url.parse(req.url);
    if(result.pathname=='/user/login' || result.pathname=='/user/add'){
        next();
    }else {
        console.log('req.session.user=============='+JSON.stringify(req.session.user));
        if(req.session.user){
            next();
        }else{
            res.json({ code: config.code.success,'message': '请登录 ',content:''});
            //res.redirect('/user/login');
        }
    }
};